<?php 
ob_start();
include('includes/connect.php'); 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Infographics</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8" />

</head>

<body>
		<div style="text-align:left">

        <?php if(!isset($_REQUEST['qattno']) || (isset($_REQUEST['qattno']) && $_REQUEST['qattno']<5))
			{
			?>
				<form name="info" id="info" method="post" action="infoshare.php">
				<?php if(!isset($_REQUEST['attempt']))
					{
				?>
			   <input type="hidden" name="user" value="<?php echo $thirdarray[0]; ?>">
				<?php
				$questions=mysql_query('select * from questions order by RAND() limit 1');
				}
				else {
					$questions=mysql_query('select * from questions where qid NOT IN (select qid from test_attempted where uid="'.$_REQUEST['user'].'" and attemt_id="'.$_REQUEST['attno'].'") order by RAND() limit 1');
					$users=mysql_query("select user from user_attempt where uid='".$_REQUEST['user']."'");
					$username=mysql_fetch_array($users);
				?>
				<input type="hidden" name="user" value="<?php echo $username['user']; ?>" />
				<?php
				}
				?>
			   <br /><br />
			   <?php 
							if(!isset($_REQUEST['qattno']))
								{
									$sr="1";
								}
								else
								{
									$sr=$_REQUEST['qattno']+1;
								}
							$i=1;
							$row_count=mysql_num_rows($questions);			
							while($row=mysql_fetch_array($questions)) {
							$que_id=$row["qid"];
							$que=$row["questions"];
							echo '&nbsp;&nbsp;'.$sr.')&nbsp'.'<input type="hidden" name="questions" value="'.$que.'"><input type="hidden" name="questions_id" value="'.$que_id.'">'.$que.'<br><br>'; 
							$sr++;
							$opt=mysql_query("select * from options as o ,questions as q where q.qid=o.qid and q.qid=$que_id"); 
							while($opt_row=mysql_fetch_array($opt))
								{
									$opt_id=$opt_row['opt_id'];
									echo '&nbsp;&nbsp;<input type="radio" name="options1" value="'.$opt_id.'">'.$opt_row['option'].'<br>';
								}							
								$i++;
								} 
							 ?>
							<br />
				<input type="hidden" value="<?php echo $_REQUEST['attempt']; ?>" name="attempts" />
				<input type="submit" value="submit" class="submit">
				</form>	<br /><br />
				<?php if(isset($_REQUEST['attempt']) && $_REQUEST['attempt']=='1')
				{
				?>
				<div><a href="qtq.php" class="su" style="text-decoration:none;">Take QTQ Test</a>&nbsp;&nbsp;<a href="qtp.php" style="text-decoration:none;" class="long_sub">Take Oreo Togetherness Pledge</a></div>		 						 			<?php
				}
				?>
	   <?php
			}
			else
			{
				header('Location:score.php');
			}
	?>
		</div>
   
</body>
</html>
<?php ob_flush(); ?>